
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
  <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
  <title>下单</title>
  <link rel="stylesheet" type="text/css" href="../css/api.css" />
  <link rel="stylesheet" type="text/css" href="../css/style.css" />
  <script type="text/javascript" src="../script/api.js"></script>
    <style type="text/css">
    .empty {
        text-align: center;
        padding: 5px 0;
    }
    .top{
      width:100%;
      height: 40px;
      margin: 40px auto 0px;
      background: #f5f5f5;
      color:#000;
      border:0px;
      display: block;
      text-align: center;
    }
    .leftreturn{
      position: absolute;
      left:5px;
      z-index: 5;
      background-image: url("../../image/leftreturn.png");
      background-position: 0px 0px;
      width:25px;
      height:25px;
      margin:7.5px 0;
    }
    .top-title{
      line-height: 40px;
      font-size: 20px;
    }
.content{
	width:100%;
	height: 500px;
	margin: 0 auto;
	background: white;
	color:#000000;
	border:0px;
	display: block;
	font-size: 14px;
}
.content-cell{
	width:100%;
	height: 50px;
	margin: 10px auto 0px;
	background: white;
	color:#000000;
	border:0px;
	display: block;
	font-size: 17px;
}
.content-text{
	width:90%;
	height: 30px;
	margin: 0 auto;
	margin-top: 0;
	color:#000000;
	border:1px;
	border-style: solid;
	border-color: #999999;
	display: block;
	font-size: 14px;
}
.button {
	width:80%;
	height: 40px;
	margin: 0 auto;
	margin-top: 15px;
	background: #0082e4;
  border-radius: 6px;
	color:#FFFFFF;
	font-size: 18px;
	border:0px;
	display: block;
}
    </style>
</head>
<body>
  <div class="empty">
    	<div class="top">
        <i class="leftreturn" onclick="Winclose();"></i>
    		<h1 class="top-title">去下单</h1>
    	</div>
    	<div class="content">
        <li class="content-cell">
          <label for="">寄件人详细地址</label>
          <input class="content-text" type="text" id="sender"/>
        </li>
    			<li class="content-cell">
    				<label for="">寄件人电话</label>
    				<input class="content-text" type="text" id="senderphone"/>
    			</li>
          <li class="content-cell">
            <label for="">收件人详细地址</label>
            <input class="content-text" type="text" id="recevier"/>
          </li>
    			<li class="content-cell">
    				<label for="">收件人电话</label>
    				<input class="content-text" type="text" id="recevierphone"/>
    			</li>
    			<li class="content-cell">
    				<label for="">揽货时间</label>
    				<input class="content-text" type="date" id="time"/>
    			</li>
    			<li class="content-cell">
    				<label for="">物品名称</label>
    				<input class="content-text" type="text" id="cname"/>
    			</li>
    			<li class="content-cell">
    				<label for="">物品重量</label>
    				<input class="content-text" type="text" id="weight"/>
    			</li>
    			<li class="content-cell">
    				<label for="">物品体积</label>
    				<input class="content-text" type="text" id="volume"/>
    			</li>
    			</div>

    		<button class="button" onclick="tiaozhuan_xiadanxuanze();">提 交</button>
    	</div>

</div>
</body>
<script type="text/javascript" src="../../script/SHA1.js"></script>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript">


  function tiaozhuan_xiadanxuanze() {
    var sender =document.getElementById('sender').value;
    var senderphone =document.getElementById('senderphone').value;
    var recevier =document.getElementById('recevier').value;
    var recevierphone =document.getElementById('recevierphone').value;
    var time =document.getElementById('time').value;
    var cname =document.getElementById('cname').value;
    var weight =document.getElementById('weight').value;
    var volume =document.getElementById('volume').value;

    if(sender==''){
      alert("请填写寄件人地址");
    }else if (senderphone=='') {
      alert("请填写寄件人电话");
    }else if(recevier==''){
      alert("请填收件人地址");
    }else if(recevierphone==''){
      alert("请填收件人电话");
    }else if(time==''){
      alert("请填揽货时间");
    }else if(cname==''){
      alert("请填物品名称");
    }else if(weight==''){
      alert("请填物品重量");
    }else if(volume==''){
      alert("请填物品体积");
    } else{
      var  user = $api.getStorage('user');
      var now = Date.now();
       appKey = SHA1("A6032422409194"+"UZ"+"808CF36B-60D4-DC5D-C9F3-FB49F9E1FB44"+"UZ"+now)+"."+now

      api.ajax({
          url: "https://d.apicloud.com/mcm/api/user/"+user[0].id+"/orderform",
          method: 'post',
          cache:  false,
          headers:{
            "X-APICloud-AppId": "A6032422409194",
            "X-APICloud-AppKey": appKey
          },
          data:{
            values: {
              "userId":user[0].id,
              "username":user[0].username,
              "sender":sender,
              "senderphone" :senderphone,
              "recevier" :recevier,
              "recevierphone" :recevierphone,
              "time" :time,
              "cname" :cname,
              "weight" :weight,
              "volume" :volume
                    }
          }
      },function(ret, err){
          if (ret) {
              alert('下单已成功');

              api.openWin({
                name: 'xiadanlist1',
                url: 'xiadanlist1.html',
                opaque: true,
                vScrollBarEnabled: false
              });

          } else {
              alert('数据库失败');
          }
      });
    }


  }
     function Winclose() {
      api.closeWin();
    }
</script>

</html>
